//
//  BaseViewController.m
//  ServerDemo
//
//  Created by rp.wang on 2018/1/10.
//  Copyright © 2018年 兰州北科维拓科技股份有限公司. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    }
    
    //------------------------------
    //隐藏分割线
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] init];
    self.navigationItem.backBarButtonItem.title = @"";
}

- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}

- (void)viewWillLayoutSubviews{
    [super viewWillLayoutSubviews];
}


- (void)warningLable:(NSString *)str
{
    
    int theLabelWith = [str boundingRectWithSize:CGSizeMake(0, 20) options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size.width;
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(DEF_SCREEN_WIDTH/2-theLabelWith/2-5, DEF_SCREEN_HEIGHT/2-30, theLabelWith+10, 60)];
    label.text = str;
    label.textColor = [UIColor blackColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:15];
    label.backgroundColor = UIColorFromRGB(0xd1d0c5);
    label.layer.cornerRadius = 5;
    label.numberOfLines = 0;
    label.clipsToBounds = YES;
    [self.view addSubview:label];
    
    
    //动画效果，1.2秒后消失
    [UIView animateWithDuration:1.5f animations:^{
        
        label.alpha = 0;
    } completion:^(BOOL finished) {
        
        [label removeFromSuperview];
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
